import java.io.File

open class Product(val name:String) {
    fun description() = "Product: $name"
    open fun load() = "nothing..."
}

class LuxuryProduct:Product("Luxury") {
    override fun load() = "LuxuryProduct loading..."
    fun special() = "LuxuryProduct special function"
}

fun main() {
    val p:Product = LuxuryProduct()
    println(p.load())

    //is判断类型
    println(p is Product)
    println(p is LuxuryProduct)
    println(p is File)

    if(p is LuxuryProduct) {
        //as转换类型
        println((p as LuxuryProduct).special())
        //p只转1次，后面的也是LuxuryProduct类型了
        println(p.special())

        println(p is Any)
        println(p.toString())
    }
}